from django.db import models

# Create your models here.

class Resource(models.Model):
    """资源表"""
    resourceName = models.CharField(max_length=20, null=True, verbose_name="资源名")
    resourceUrl = models.FileField(upload_to='upload_file', verbose_name="资源路径")
    resourceSize = models.IntegerField(null=True, verbose_name="资源大小")
    remark = models.TextField(null=True, verbose_name="资源描述")
    keyword = models.CharField(max_length=128, null=True, verbose_name="关键词")
    resourceTypeId = models.IntegerField(null=True, verbose_name="所属类型")
    type = models.IntegerField(default=0, verbose_name="资源类别")
    starlevel = models.IntegerField(default=0, verbose_name="资源评价几星")
    score = models.IntegerField(null=True, verbose_name="资源分")
    userId = models.IntegerField(null=True, verbose_name="用户id")
    status = models.IntegerField(default=1, verbose_name="资源是否审核状态")
    delFlag = models.IntegerField(default=0, verbose_name="资源是否删除")
    create_time = models.DateTimeField(auto_now_add=True,verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now_add=True,verbose_name="更新时间")

class ResourceEx(models.Model):
    """下载量，收藏量，访问量，"""
    resourceId = models.IntegerField()
    downloads = models.IntegerField()
    collections = models.IntegerField()
    reads = models.IntegerField()


class ResourceType(models.Model):
    """资源分类表"""
    name = models.CharField(max_length=20, verbose_name="资源类型名称")
    parentId = models.IntegerField(verbose_name="父资源id")

class Collection(models.Model):
    """文件收藏表"""
    userId = models.IntegerField(verbose_name="用户的id")
    resource = models.IntegerField(verbose_name="资源id")
    create_time = models.DateTimeField(auto_now_add=True)


class Comment(models.Model):
    """资源评论"""
    userId = models.IntegerField()
    resourceId = models.IntegerField()
    content = models.CharField(max_length=200)
    starNum = models.IntegerField(verbose_name="星星")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="发布评论时间")

class PointDetail(models.Model):
    """积分明细表"""
    userId = models.IntegerField()
    resourceId = models.IntegerField()
    changePoint = models.IntegerField()
    content = models.CharField(max_length=20)
    create_time = models.DateTimeField(auto_now_add=True)





